package tiantao.taogu.TgEnum;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum PayChannelTypeEnum {

  WEIXIN_PAY("微信支付", 0, "wx"),
  ALI_APP_APY("支付宝", 1, "alipay"),
  WX_PUB_PAY("微信公众号支付", 2, "wx_pub"),
  REGISTRATION_CARD("就诊卡", 3, "registration_card"),
  UPACP("银联支付", 4, "upacp"),
  FREE_PAY("免费", 5, "free_pay"),
  CBC_ORIGIN("建行支付",6, "cbc_pay"),
  WX_QR_PAY("微信扫码支付",7, "wx_qr_pay"),
  WEIXIN_ORIGINAL_PAY("微信支付", 8, "c_wx"),
  WX_PUB_ORIGINAL_PAY("微信公众号支付", 9, "c_wx_pub"),
  ALI_APP_ORIGINAL_PAY("支付宝支付", 10, "c_ali_pay"),
  ICBC_ORIGINAL_PAY("工行支付", 12, "c_icbc_pay"),
  TAOGU_WEIXIN_ORIGINAL_PAY("桃谷微信支付", 13, "tg_wx"),
  TAOGU_ALI_APP_ORIGINAL_PAY("桃谷支付宝支付", 14,"tg_ali_pay"),
  WX_INSURANCE_PAY("微信医保支付", 15, "c_wx_ins"),
  WX_PAY_H5("微信H5支付", 16, "c_wx_h5"),
  WX_PAY_QR("微信二维码支付", 17, "c_wx_qr"),
  HIZPAY_WEIXIN_PAY("海鹚微信支付", 18, "hiz_wx"),
  HIZPAY_ALI_PAY("海鹚支付宝支付", 19, "hiz_ali"),
  CCB_PAY("建行聚合支付", 20, "c_ccb"),
  ALI_H5_ORIGINAL_PAY("支付宝网页支付", 21, "c_ali_pay_h5"),
  ;

  private String name;
  private int channelId;
  private String channel;

  private PayChannelTypeEnum(String name, int channelId, String channel) {
    this.name = name;
    this.channelId = channelId;
    this.channel = channel;
  }

  public static PayChannelTypeEnum fromChannel(String channel) {
    for (PayChannelTypeEnum o : PayChannelTypeEnum.values()) {
      if (o.channel.equals(channel)) {
        return o;
      }
    }
    return null;
  }

  public static PayChannelTypeEnum fromName(String name) {
    for (PayChannelTypeEnum o : PayChannelTypeEnum.values()) {
      if (o.getName().equals(name)) {
        return o;
      }
    }
    return null;
  }

  public static PayChannelTypeEnum fromId(int id) {
    for (PayChannelTypeEnum o : PayChannelTypeEnum.values()) {
      if (o.getChannelId() == id) {
        return o;
      }
    }
    return null;
  }

  public static List<Map<String, Object>> getAllChannel() {
    List<Map<String, Object>> channelList = new ArrayList<Map<String, Object>>();
    for (PayChannelTypeEnum o : PayChannelTypeEnum.values()) {
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("channelId", o.getChannelId());
      map.put("name", o.getName());
      channelList.add(map);
    }
    return channelList;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getChannelId() {
    return channelId;
  }

  public void setChannelId(int channelId) {
    this.channelId = channelId;
  }

  public String getChannel() {
    return channel;
  }

  public void setChannel(String channel) {
    this.channel = channel;
  }

}